package com.example.demo.controller;

import com.example.demo.entity.Entertainment;
import com.example.demo.enums.ResultEnum;
import com.example.demo.service.KyService;
import com.example.demo.vo.ResultVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/ky")
public class KyController {
    @Autowired
    private KyService kyService;

    @RequestMapping("/findKy")
    public Object findKy(String page,String rows){
        Page<Object> pageInfo = PageHelper.startPage(Integer.valueOf(page),Integer.valueOf(rows));
        List<Entertainment> lists = kyService.findKy();
        return lists;
    }
    @RequestMapping("/addKy")
    public ResultVO addKy(@RequestParam Map<String,String> map){
        kyService.addKy(map);
        return new ResultVO(ResultEnum.SUCCESS,"添加成功");
    }
    @RequestMapping("/updateKy")
    public ResultVO updateKy(@RequestParam Map<String,String> map){
        kyService.updateKy(map);
        return new ResultVO(ResultEnum.SUCCESS,"修改成功");
    }
    @RequestMapping("/delByEid")
    public ResultVO delByEid(String eid){
        kyService.delByEid(eid);
        return new ResultVO(ResultEnum.SUCCESS,"删除成功");
    }
    @RequestMapping("/findByEid")
    public Object findByEid(String eid){
        Entertainment entertainment = kyService.findByEid(eid);
        return entertainment;
    }
}
